package converter.core.utils;

import java.io.File;

/**
 * Created with IntelliJ IDEA.
 * User: Snark
 * Date: 31.03.13
 * Time: 16:16
 * To change this template use File | Settings | File Templates.
 */
public class FileFilter implements java.io.FileFilter {

    private String extension;

    public FileFilter(String extension) {
        this.extension = extension;
    }

    public static java.io.FileFilter xmlFilter() {
        return new FileFilter("xml");
    }

    @Override
    public boolean accept(File file) {
        if (file.isDirectory()) {
            return true;
        }
        String ext = FileUtil.getExtension(file);
        if (ext != null) {
            if (ext.equalsIgnoreCase(extension)) {
                return true;
            }
        }
        return false;
    }
}
